
// 登录与注册的模块
const state = {
  code: "",
  token: '',
  userInfo: {},
  info: []
};
const mutations = {
  SET_TOKEN_PERSIST(state, token) {
    state.token = token;
  },
  // 清除本地数据
  CLEAR_TOKEN_PERSIST(state) {
    // 帮仓库中先关用户信息清空
    state.token = '';
    state.userInfo = {};
  },
  SET_INFO_PERSIST(state, info) {
    state.info = info;
  },
  // 清除本地数据
  CLEAR_INFO_PERSIST(state) {
    state.info = [];
  },
};
const actions = {
  // 保存登录凭证
  setToken({ commit }, token) {
    commit("SET_TOKEN_PERSIST", token);
  },
  // 清除已过期的token
  clearToken({ commit }) {
    commit("CLEAR_TOKEN_PERSIST");
  },
  setLoginInfo({ commit }, info) {
    commit("SET_INFO_PERSIST", info);
  },
  clearLoginInfo({ commit }) {
    commit("CLEAR_INFO_PERSIST");
  },
};
const getters = {};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
